import {baseUrl} from "@/config/env";
import userApi from "@/api/sys/userApi";
import userOption from "@/option/sys/userOption";
import optionUtils from "@/option/optionUtils";
import startSearchModel from "@/config/startSearchModel";

const userListOption = userOption();

export default () => {
    return {
        index: true,
        submitText: '修改',
        size: 'default',
        labelWidth: 100,
        menuAlign: 'center',
        menuPosition: "right",
        searchIndex: 2,
        searchMenuSpan: 8,
        searchIcon: true,
        column: [
            {
                label: '管理机构',
                prop: 'deptId',
                span: 12,
                type: "tree",
                dicUrl: baseUrl + "/start/sysDept/listTree",
                props: {
                    label: "deptName",
                    value: "id",
                },
                showColumn: true,
            },
            {
                search: true,
                searchModel: startSearchModel.LIKE_RIGHT,
                label: '用户',
                prop: 'userFinalName',
                span: 12,
                display: false,
            },
            {
                label: '用户名',
                span: 12,
                prop: 'userId',
                type: "table",
                showColumn: false,
                hide: true,
                addDisplay: true,
                props: {
                    label: 'userFinalName',
                    value: 'id'
                },
                children: userListOption,
                onLoad: (onLoadParams, callback) => {
                    // console.log("数据加载", onLoadParams)
                    onLoadParams.pageDefinition = userApi.list
                    onLoadParams.valueDefinition = userApi.getUserInfo
                    onLoadParams.option = userListOption;
                    optionUtils.tableOnLoad(onLoadParams, callback)
                },
            },
            {
                label: '管理级别',
                span: 12,
                prop: 'manageLevel',
                type: "select",
                dicUrl: baseUrl + "/start/sysDictionaryItem/listByDictionaryCode",
                dicMethod: "get",
                dicQuery: {dictCode: "user_manage_dept_levels"},
                props: {
                    label: 'dictName',
                    value: 'dictVal',
                },
            },
            {
                label: '序号',
                prop: 'sort',
                type: "number",
                span: 12,
            },

        ]
    }
}
